package com.qjl.shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qjl.shopping.bean.Admin;
import com.qjl.shopping.bean.Orders;
import com.qjl.shopping.bean.ShopCar;
import com.qjl.shopping.dao.AdminMapper;
import com.qjl.shopping.dao.ShopCarMapper;
import com.qjl.shopping.service.AdminService;
import com.qjl.shopping.service.ShopCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author liguanghui
 * @Date 2023/5/3
 */
@Service
public class ShopCarServiceImpl extends ServiceImpl<ShopCarMapper, ShopCar> implements ShopCarService {
    @Autowired
    private ShopCarMapper shopCarMapper;
    @Override
    public Page<ShopCar> selectPage(int pageNum, int pageSize,int userId,int itemId, int status) {
        Page<ShopCar> page = new Page<>(pageNum,pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("shopcar_id");
        if(userId!=0){
            queryWrapper.eq("shopcar_user_id",userId);
        }
        if(itemId!=0){
            queryWrapper.eq("shopcar_item_id",itemId);
        }
        if(status!=-1){
            queryWrapper.eq("shopcar_status",status);
        }
        Page<ShopCar> shopCarPage = shopCarMapper.selectPage(page,queryWrapper);
        System.out.println(shopCarPage);
        return shopCarPage;
    }
}
